/*     */ package com.qmsk.business.task.insuranceRecord.controller;
/*     */ 
/*     */ import com.qmsk.business.info.taskRemind.dao.TaskRemindDao;
/*     */ import com.qmsk.business.manage.user.dao.UserDAO;
/*     */ import com.qmsk.business.member.member.dao.MemberDAO;
/*     */ import com.qmsk.business.task.insuranceRecord.dao.InsuranceRecordDao;
/*     */ import com.qmsk.business.weixin.customMenu.weiXinUtil.WeiXinUtil;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"insuranceRecord"})
/*     */ public class InsuranceRecordController
/*     */ {
/*  35 */   private static final Logger logger = Logger.getLogger(InsuranceRecordController.class);
/*     */ 
/*     */   @Autowired
/*     */   private InsuranceRecordDao dao;
/*     */ 
/*     */   @Autowired
/*     */   private UserDAO userDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberDAO memberDAO;
/*     */ 
/*     */   @Autowired
/*     */   private TaskRemindDao taskRemindDao;
/*     */ 
/*     */   @RequestMapping(value={"find/insuranceList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize) { nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  52 */       Map params = new HashMap();
/*  53 */       String shopId = RequestUtils.getString(request, "shopId");
/*  54 */       String openId = RequestUtils.getString(request, "openId");
/*  55 */       String id = RequestUtils.getString(request, "id");
/*     */ 
/*  57 */       MapUtils.addToMap(params, "shopId", shopId);
/*  58 */       MapUtils.addToMap(params, "openId", openId);
/*  59 */       MapUtils.addToMap(params, "id", id);
/*  60 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  61 */         nPageSize);
/*  62 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  64 */       logger.error(e);
/*  65 */       ResponseUtils.setErrorMsgResponse(
/*  66 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/insuranceListOfUserId/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void insuranceListOfUserId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  73 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  75 */       Map params = new HashMap();
/*  76 */       MapUtils.addToMap(params, "id", RequestUtils.getStringOfId(request));
/*  77 */       String shopId = RequestUtils.getString(request, "shopId");
/*  78 */       String userId = RequestUtils.getString(request, "userId");
/*  79 */       MapUtils.addToMap(params, "shopId", shopId);
/*  80 */       MapUtils.addToMap(params, "userId", userId);
/*  81 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  82 */         nPageSize);
/*  83 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  85 */       logger.error(e);
/*  86 */       ResponseUtils.setErrorMsgResponse(
/*  87 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert/insertInfo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  97 */       int nResult = 0;
/*  98 */       String sData = RequestUtils.getStringOfData(request);
/*  99 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 100 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 101 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 102 */         g.autoAddHeadData("SubMitdate", new Date());
/* 103 */         g.autoAddHeadData("Status", Integer.valueOf(0));
/* 104 */         nResult = this.dao.applyUpdates(p);
/* 105 */         if (nResult > 0) {
/* 106 */           Long userId = ObjectComm.objectToLong(g.getValueOfName("userId"));
/* 107 */           Long CustomerID = ObjectComm.objectToLong(g.getValueOfName("CustomerID"));
/* 108 */           Long memberId = ObjectComm.objectToLong(g.getValueOfName("memberId"));
/* 109 */           String customerName = ObjectComm.objectToString(g.getValueOfName("CustomerName"));
/* 110 */           String mp = ObjectComm.objectToString(g.getValueOfName("LinkPhone"));
/* 111 */           String OrderDate = ObjectComm.objectToString(g.getValueOfName("OrderDate"));
/* 112 */           String License = ObjectComm.objectToString(g.getValueOfName("License"));
/* 113 */           String ComName = ObjectComm.objectToString(g.getValueOfName("ComName"));
/* 114 */           String shopId = ObjectComm.objectToString(g.getValueOfName("shopId"));
/* 115 */           String custOpenId = this.memberDAO.getOpenId(CustomerID);
/* 116 */           GsonHeadOneRow user = this.userDao.selectUserById(userId);
/* 117 */           Long id = this.dao.getLastId();
/* 118 */           String content = "保险预约通知:\n客户姓名：" + customerName + "\n联系电话：" + mp + "\n车牌号：" + License + "\n保险到期：" + OrderDate + "\n保险公司：" + ComName;
/* 119 */           if (user != null) {
/* 120 */             String openId = (String)user.getValueOfName("openId");
/* 121 */             String name = (String)user.getValueOfName("name");
/* 122 */             String userMp = (String)user.getValueOfName("mp");
/* 123 */             WeiXinUtil.sendTextMessageOfMain("保险预约受理通知:\n尊敬的" + customerName + ",我们已经收到您的保险预约信息,我是您的保险顾问：" + name + ",\n联系电话：" + userMp, custOpenId);
/* 124 */             if (StringUtils.isNotEmpty(openId))
/*     */             {
/* 126 */               WeiXinUtil.sendTextMessageOfMain(content, openId);
/*     */             }
/*     */ 
/* 129 */             String[] head = { "CreateTime", "AssignTime", "TaskMemo", "Status", "License", "CustName", "Mp", "CustID", "MemberID", "ShopId", "AssignId", "AssignName", "RemindID", "taskDetilId" };
/* 130 */             Object[] data = { new Date(), OrderDate, content, Integer.valueOf(1), License, customerName, mp, CustomerID, memberId, shopId, userId, name, Integer.valueOf(9), id };
/* 131 */             nResult = this.taskRemindDao.insertGsonHeadOneRow(new GsonHeadOneRow(head, data));
/*     */           } else {
/* 133 */             String[] head = { "CreateTime", "AssignTime", "TaskMemo", "Status", "License", "CustName", "Mp", "CustID", "MemberID", "ShopId", "RemindID", "taskDetilId" };
/* 134 */             Object[] data = { new Date(), OrderDate, content, Integer.valueOf(0), License, customerName, mp, CustomerID, memberId, shopId, Integer.valueOf(9), id };
/* 135 */             nResult = this.taskRemindDao.insertGsonHeadOneRow(new GsonHeadOneRow(head, data));
/*     */           }
/* 137 */           if (nResult > 0)
/*     */           {
/* 139 */             DbConnection.commit();
/*     */           }
/*     */           else DbConnection.rollback();
/*     */         }
/*     */         else {
/* 144 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 147 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 148 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 149 */         response);
/*     */     } catch (Exception e) {
/* 151 */       logger.error(e);
/* 152 */       DbConnection.rollback();
/* 153 */       ResponseUtils.setErrorMsgResponse(
/* 154 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 155 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 165 */       int nResult = 0;
/* 166 */       String sData = RequestUtils.getStringOfData(request);
/* 167 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 168 */       if (p != null) {
/* 169 */         nResult = this.dao.applyUpdates(p);
/* 170 */         if (nResult > 0)
/* 171 */           DbConnection.commit();
/*     */         else {
/* 173 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 176 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 177 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 178 */         response);
/*     */     } catch (Exception e) {
/* 180 */       logger.error(e);
/* 181 */       DbConnection.rollback();
/* 182 */       ResponseUtils.setErrorMsgResponse(
/* 183 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 184 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 192 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 194 */       String[] strParams = id.split(",");
/* 195 */       int nResult = this.dao.deleteParams(strParams);
/* 196 */       if (nResult > 0)
/* 197 */         DbConnection.commit();
/*     */       else {
/* 199 */         DbConnection.rollback();
/*     */       }
/* 201 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 202 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 203 */         response);
/*     */     } catch (Exception e) {
/* 205 */       DbConnection.rollback();
/* 206 */       logger.error(e);
/* 207 */       ResponseUtils.setErrorMsgResponse(
/* 208 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 209 */         e.getMessage(), response); }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/deal"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void deal(HttpServletRequest request, HttpServletResponse response) {
/*     */     try {
/* 216 */       int nResult = 0;
/* 217 */       Long id = null;
/* 218 */       String sData = RequestUtils.getStringOfData(request);
/* 219 */       String reply = RequestUtils.getString(request, "reply");
/* 220 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 221 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 222 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListUpdateRows().get(0);
/* 223 */         g.autoInsertHeadData("CancelDate", new Date());
/* 224 */         g.autoInsertHeadData("replyDate", new Date());
/* 225 */         id = ObjectComm.objectToLong(g.getValueOfName("id"));
/* 226 */         String openId = this.dao.getOpenIdById(id);
/*     */ 
/* 228 */         nResult = this.dao.applyUpdates(p);
/* 229 */         if (nResult > 0) {
/* 230 */           DbConnection.commit();
/* 231 */           WeiXinUtil.sendTextMessageOfMain("保险预约处理情况:\n" + reply, openId);
/*     */         } else {
/* 233 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 236 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 237 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 238 */         response);
/*     */     } catch (Exception e) {
/* 240 */       logger.error(e);
/* 241 */       DbConnection.rollback();
/* 242 */       ResponseUtils.setErrorMsgResponse(
/* 243 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 244 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.insuranceRecord.controller.InsuranceRecordController
 * JD-Core Version:    0.5.3
 */